import javax.swing.*;
import java.awt.*;


public class PlayerPanel extends JPanel{
	CardClient main;
	int link;
	String pic;
		
    public PlayerPanel(CardClient main) {
    super();
    this.main=main;
    }
    
    public void setLink(int link){
    	if(link<0||link>2) return;
    	this.link=link;
    }
    
    public void setPic(String pic){
    	this.pic=pic;
    }
    
    public void paintComponent(Graphics g) {
		Graphics2D comp = (Graphics2D) g;
		comp.setColor(main.getContentPane().getBackground());
		comp.fillRect(0, 0, this.getSize().width, getSize().height);
		if (!main.table.seat[link]) return;
		String pic1 = pic;
		if ((main.table.gameState == Table.PLAY || main.table.gameState == Table.NEWLOOP) && main.table.landlord == main.table.players[link].id) {
			pic1 = "地主.gif";
		}
		Toolkit tk = Toolkit.getDefaultToolkit();
		Image img = tk.getImage("images/" + pic1);
		comp.drawImage(img, 0, 20, this);
	}
}